<?php
include('../__global.php');

class fetch_api extends ml_controller
{
	private $url;
	public function initParam()
	{
		$this->url = $this->input('url' , 'g');
	}

	public function checkParam(){}

	private function _getTaobaoTmallData()
	{
		$a = parse_url($this->url);
		parse_str($a['query'] , $a);
		$id = $a['id'];

		$oApi = new ml_model_openapi_topsdk();
		$param = array(
			 'numIid' => $id
		);
		$rs = $oApi->getOneGoods($param);

		$data = array(
			'gd_pic' => $rs['item']['pic_url'],
			'gd_small_pic' => $rs['item']['pic_url'].'_200x200.jpg',
			'gd_price' => $rs['item']['price'],
			'gd_shop' => $rs['item']['nick'],
			'gd_url' => $this->url,
			'gd_title' => $rs['item']['title'],
		);
		return $data;
	}

	public function main(){

		$data = $this->_getTaobaoTmallData();
		
		$this->api_output(ML_RCODE_SUCC , $data);
	}

}

new fetch_api();
?>